﻿Public Class Remedy_InputBox
    Private isLimiteKeyPress As Boolean = True
    Public Sub New()

        ' 此调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        ' 在 InitializeComponent() 调用之后添加任何初始化。

    End Sub
    Public Sub New(ByVal Title As String)

        ' 此调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        ' 在 InitializeComponent() 调用之后添加任何初始化。
        Me.Text = Title
    End Sub
    Public Sub New(ByVal Title As String, ByVal DefaultValue As String)

        ' 此调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        ' 在 InitializeComponent() 调用之后添加任何初始化。
        Me.Text = Title
        Me.TextBox1.Text = DefaultValue
    End Sub
    Public Sub New(ByVal Title As String, ByVal defaultValue As String, ByVal KeyPressLimite As Boolean)
        InitializeComponent()
        isLimiteKeyPress = KeyPressLimite
        Me.Text = Title
        Me.TextBox1.Text = defaultValue
    End Sub
    Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        If isLimiteKeyPress = False Then Return
        If Asc(e.KeyChar) = 8 Then Return
        If Asc(e.KeyChar) < 48 Or Asc(e.KeyChar) > 57 Then e.Handled = True
    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        InputText = TextBox1.Text
    End Sub

    Private Sub Btn_Cancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Btn_Cancel.Click
        SelectInput = InputDialogResult.Cancel
    End Sub

    Private Sub Btn_Ok_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Btn_Ok.Click
        SelectInput = InputDialogResult.OK
        Me.Close()
    End Sub

    Private Sub Remedy_InputBox_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

    End Sub

    Private Sub Remedy_InputBox_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ChangeButtonFromFrm(Me)
    End Sub
    Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        If m.Msg = 161 And m.WParam = 20 Then
            SelectInput = InputDialogResult.Cancel
        End If
        MyBase.WndProc(m)
    End Sub
End Class